package org.aeon.foa.app;

import org.aeon.foa.entity.Meals;
import org.aeon.foa.entity.Order;

import java.util.List;
import java.util.Scanner;

/**
 * @projectName: easytaskkit
 * @package: org.aeon.foa.app
 * @className: Menu
 * @author: MissingAeon
 * @date: 2024/1/2 18:01
 * @description:
 */
public class Menu {  // 展示菜单
    public static void menu() {
        System.out.println("***************************************");
        System.out.println("1、我要订餐");
        System.out.println("2、查看餐袋");
        System.out.println("3、签收订单");
        System.out.println("4、删除订单");
        System.out.println("5、我要点赞");
        System.out.println("6、退出系统");
        System.out.println("***************************************");
        System.out.print("请选择：");
    }

    // 订餐页
    public static void orderingPage(List<Meals> meals) {
        System.out.printf("%6s%6s%6s\n", "序号", "菜名", "单价");
        meals.stream().map(obj -> String.format("%6d%6s%6.2f", obj.getNumber(), obj.getDishName(), obj.getUnitPrice())).forEach(System.out::println);
    }

    public static void likePage(List<Meals> meals) {
        System.out.printf("%6s%6s%6s%6s\n", "序号", "菜名", "单价", "点赞");
        meals.stream().map(obj -> String.format("%6d%6s%6.2f%6d", obj.getNumber(), obj.getDishName(), obj.getUnitPrice(), obj.getLike())).forEach(System.out::println);
    }

    public static void orderSettlement(Order order) {
        System.out.printf("您订的是: %s \n送餐时间: %d点\n餐费: %.2f元，送餐费%.2f元，总计: %.2f元\n", order.getFoodInfo(), order.getDeliveryTime(), order.getMealExpenses(), order.getShippingFees(), order.getMealExpenses() + order.getShippingFees());
    }

    public static void fallback(Scanner in) {
        System.out.println("输入0返回:");
        in.nextLine();
    }

    public static void mealBagPage(List<Order> orders) {
        System.out.printf("%6s%6s%6s%6s%6s%6s%6s\n", "序号", "订餐人", "餐品信息", "送餐日期", "送餐地址", "总金额", "订单状态");
        orders.stream().map(obj -> String.format("%6s%6s%6s%6d%6s%6.2f%6s", obj.getNumber(), obj.getOrdererName(), obj.getFoodInfo(), obj.getDeliveryDate(), obj.getDeliveryAddr(), obj.getMealExpenses() + obj.getShippingFees(), obj.getState() ? "已完成" : "已预订")).forEach(System.out::println);
    }
}
